package com.itheima.project.web;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.core.enums.trade.TradingEnum;
import com.itheima.project.face.CreditPayFace;
import com.itheima.project.utils.ResponseWrapBuild;
import com.itheima.project.vo.trade.TradingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CreditPayFace.java
 * @Description 信用支付方式：免单、挂账
 */
@RestController
@RequestMapping("trade-credit")
@Api(tags = "信用支付controller")
public class CreditPayController {

    @Autowired
    CreditPayFace creditPayFace;


    /***
     * @description 免单：商户对用户免单
     * @param tradingVo 交易单
     * @return  交易单
     */
    @PostMapping("create-creditmd-trading")
    @ApiOperation(value = "免单",notes = "免单")
    @ApiImplicitParam(name = "tradingVo",value = "交易单",required = true,dataType = "TradingVo")
    ResponseWrap<TradingVo> createCreditMdTrading(TradingVo tradingVo){
        TradingVo tradingVoResult = creditPayFace.createCreditMdTrading(tradingVo);
        return ResponseWrapBuild.build(TradingEnum.SUCCEED,tradingVoResult);
    }
    /***
     * @description 挂账：用户挂账
     * @param tradingVo 交易单
     * @return  交易单
     */
    @PostMapping("create-creditgz-trading")
    @ApiOperation(value = "挂账",notes = "挂账")
    @ApiImplicitParam(name = "tradingVo",value = "交易单",required = true,dataType = "TradingVo")
    ResponseWrap<TradingVo> createCreditGzTrading(TradingVo tradingVo) {
        TradingVo tradingVoResult = creditPayFace.createCreditGzTrading(tradingVo);
        return ResponseWrapBuild.build(TradingEnum.SUCCEED,tradingVoResult);
    }
}
